package action.agent;

import org.apache.struts2.ServletActionContext;

import service.interf.IIfwSrouterMap;
import action.common.MyBaseAction;

import com.opensymphony.xwork2.ModelDriven;

import dao.pojo.IfwSrouterMap;

/**
 * 点卡使用情况
 * 
 * @author Administrator
 * 
 */
public class IfwSrouterMapAction extends MyBaseAction<IfwSrouterMap> implements
		ModelDriven<IfwSrouterMap> {

	private static final long serialVersionUID = 1L;
	private IIfwSrouterMap srouterMap;
	private String rlyModel;
	private String deviceModel;
	private String supplier;

	public void setSrouterMap(IIfwSrouterMap srouterMap) {
		this.srouterMap = srouterMap;
	}

	public void setRlyModel(String rlyModel) {
		this.rlyModel = rlyModel;
	}

	public void setDeviceModel(String deviceModel) {
		this.deviceModel = deviceModel;
	}

	public void setSupplier(String supplier) {
		this.supplier = supplier;
	}

	public IfwSrouterMapAction() {
		super(IfwSrouterMap.class);
	}

	public IfwSrouterMap getModel() {
		return model;
	}

	/**
	 * 添加
	 */
	public void add() {
		String r = "";
		try {
			r = srouterMap.add(rlyModel, deviceModel, model.getSn(), supplier,
					model.getNote());
		} catch (Exception e) {
			r = errorHandle.handleErr(e);
		}
		servletHandle.writeToClient1(ServletActionContext.getResponse(), r);
	}

	/**
	 * 初始化列表
	 */
	public void findbyFwSN() {
		String x = "";
		try {
			if (model.getFwsn() != null) {
				x = srouterMap.findById("IfwSrouterMap", "*", "json", "fwsn",
						model.getFwsn());
			}
			if (x == null || x.equals("")) {
				x = "0";
			}
		} catch (Exception e) {
			x = errorHandle.handleErr(e);
		}
		servletHandle.writeToClient(ServletActionContext.getResponse(), x);
	}

}
